package cn.com.test;


import cn.com.bean.Person;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;

public class BeanLifeCycle {

	public static void main(String[] args) {

		System.out.println("现在开始初始化容器");




		AnnotationConfigApplicationContext factory = new  AnnotationConfigApplicationContext("cn.com");

		System.out.println("容器初始化成功");
		//得到Preson，并使用
		Person person = factory.getBean("person",Person.class);
		System.out.println(person);

		System.out.println("person初始化");
		Person person1 = new Person();
		System.out.println(person1);

		System.out.println("getBeanDefinition");
		System.out.println(factory.getBeanFactory().getBeanDefinition("person"));

		for (String beanDefinitionName : factory.getBeanDefinitionNames()) {
			System.out.println("getBeanDefinitionNames：" + beanDefinitionName);
		}

		System.out.println("现在开始关闭容器！");
		factory.start();
		factory.registerShutdownHook();
		//((ClassPathXmlApplicationContext)factory).registerShutdownHook();


		System.out.println(person1);
	}
}

